<template>
  <div class="pay-amount">
    <div class="amount">
      <span>充值金额:</span>
      <span>￥{{ amount }}</span>
    </div>
    <div class="pay-warp">
      <div
        :key="item.id"
        v-for="(item, index) in rechargeAmount"
        class="pay-amount-item"
        :class="{ current: index === currentIndex }"
        @click="itemClick(index, item.amount)"
      >
        ￥{{ item.amount }}
      </div>
    </div>
  </div>
</template>

<script lang="js">
import {defineComponent, reactive, ref} from 'vue'
import{ rechargeAmount} from '@/common/local-data'
import { ONE_CARD_DEFAULT_RECHARGE_AMOUNT} from '@/common/constant'
export default defineComponent({
  props: {

  },
  components: {

  },
  emits:['amountChange'],
  setup(props,{emit}) {
    const currentIndex=ref(0)
    const amount=ref(ONE_CARD_DEFAULT_RECHARGE_AMOUNT)
    const itemClick=(index,amount1)=>{
      currentIndex.value=index
      amount.value=amount1
      emit('amountChange',amount.value)
    }
    return {
      currentIndex,
      rechargeAmount,
      amount,
      itemClick
    }

  }
})
</script>

<style scoped lang="less">
.pay-amount {
  .amount {
    padding-left: 2vw;
    display: flex;
    align-items: center;
    margin: 2vh 0 4vh 0;
    font-weight: 550;
    span:nth-child(1) {
      width: 24vw;
    }
    span:nth-child(2) {
      flex: 1;
      padding-bottom: .4vh;
      // text-align: center;
      border-bottom: 1px solid #f0f0f0;
    }
  }
  .pay-warp {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .pay-amount-item {
      width: 28%;
      display: flex;
      justify-content: center;
      box-sizing: border-box;
      padding: 2.4vh 0;
      border: 1px solid #ccc;
      margin-bottom: 4.8vh;
      border-radius: 6px;
    }
    .current {
      background-color: rgb(116, 192, 251);
      color: white;
    }
  }
}
</style>
